<?php

namespace forfun\service;

use forfun\repository\QuestionRepository;
use restphp\biz\PageParam;
use restphp\utils\RestStringUtils;

class QuestionService {
    public static function getQuestionList($key, $page) {
        $questionRepository = new QuestionRepository();
        $queryRule = array(
            'rule' => array(
            ),
            'page_param' => PageParam::getInstance($page, APP_DATA_LIST_PAGE_SIZE),
            'order' => ' order by id desc'
        );
        if (!RestStringUtils::isBlank($key)) {
            $queryRule['rule']['title'] = array('title like :title', array('title'=>"%$key%"));
        }
        $questions = $questionRepository->select($queryRule);
        return $questions;
    }
}